package lab03.test14;

import java.sql.*;

/**
 * Created by JAVA on 2017/12/13.
 */
public class Test14 {
        public static void main(String[] args) {

            Connection connection=null;
            Statement statement=null;
            ResultSet resultSet=null;
            String sql1="SELECT* from t_student";
            String sql2="delete from t_student where id=5";
            String sql3="update t_student set department='信息与工程学院' where id=3 ";
            try {
                Class.forName("com.mysql.jdbc.Driver ");
                connection= DriverManager.getConnection(
                        "jdbc:mysql://localhost:3306/java_2017",
                        "root",
                        "123456"
                );
                statement=connection.createStatement();
                //ResultSet:查
                resultSet = statement.executeQuery(sql1);
                statement.execute(sql2);
                statement.execute(sql3);
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (SQLException e) {
                e.printStackTrace();
            } finally {
                try {
                    statement.close();
                    connection.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
        }
}
